package com.apiversion.apiversion.controller.v1;

import com.apiversion.apiversion.configuration.ApiVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: admin
 * @Description:
 * @Date: 2019/1/2 14:00
 */

@RestController()

@RequestMapping("/{version}/home")
public class HomeController {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @GetMapping("/hello")
    public String hello() {
        String res = redisTemplate.opsForValue().get("1");
        System.out.println(res);
        return "hello-V1";
    }


    @GetMapping("/get/{key}")
    public String get(@PathVariable String key) {
        String res = redisTemplate.opsForValue().get(key);
        System.out.println(res);
        return res;
    }

    @GetMapping("/set/{key}/{value}")
    public String set(@PathVariable String key, @PathVariable String value) {
        redisTemplate.opsForValue().set(key, value);
        return "hello-V1";
    }
}
